Optimize factorization hot paths (~25% speedup on factorize64)#67
Merged
sylvestre merged 3 commits intouutils:mainfrom Mar 24, 2026
Merged
Optimize factorization hot paths (~25% speedup on factorize64)#67sylvestre merged 3 commits intouutils:mainfrom
sylvestre merged 3 commits intouutils:mainfrom
Conversation
Contributor
sylvestre
commented
Mar 24, 2026
- Update tsqrt bound after extracting factors in trial division
- Reorder primality check to after trial division in factorize64
- Add 5th/7th perfect power checks in factorize128_advanced
- Add #[inline] on is_prime64, is_prime64_miller, is_prime32_miller
- Pre-allocate vectors in factorization and primality functions
- Use /= in trial division inner loops
- Update tsqrt bound after extracting factors in trial division - Reorder primality check to after trial division in factorize64 - Add 5th/7th perfect power checks in factorize128_advanced - Add #[inline] on is_prime64, is_prime64_miller, is_prime32_miller - Pre-allocate vectors in factorization and primality functions - Use /= in trial division inner loops
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
+ Coverage 78.64% 85.07% +6.42%
==========================================
Files 13 15 +2
Lines 2585 3490 +905
Branches 230 246 +16
==========================================
+ Hits 2033 2969 +936
+ Misses 552 520 -32
- Partials 0 1 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Merging this PR will improve performance by 52.23%
Performance Changes
Comparing Footnotes
|
num-primes uses thread_rng() internally, making its benchmarks non-deterministic. CodSpeed's instruction-counting simulation amplifies this into huge false regressions. Gate all num-primes bench_functions with #[cfg(feature = "num-primes")] and build without the feature in CodSpeed CI.
num-primes uses thread_rng() internally, making its benchmarks non-deterministic and causing false regressions in CodSpeed CI. Remove num-primes from default features so it's excluded from CI benchmarks. All num-primes bench_functions are gated behind #[cfg(feature = "num-primes")] - use --features num-primes to include them for local comparison.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.